package com.lost.octopus.test.es7demo.exception;

import java.io.Serializable;

public interface ResponseCode extends Serializable {

    int getCode();

    String getMessage();

    default String strCode() {
        return Integer.toString(getCode());
    }

    static ResponseCode of(int code, String message) {
        return new SimpleResponseCode(code, message);
    }

    public class SimpleResponseCode implements ResponseCode, Serializable {
        private final int code;
        private final String message;

        public SimpleResponseCode(int code, String message) {
            this.code = code;
            this.message = message;
        }

        @Override
        public int getCode() {
            return code;
        }

        @Override
        public String getMessage() {
            return message;
        }
    }
}
